package chapter

import (
	"gohub/app/models"
	"gohub/pkg/database"
)

// Chapter 模型
type Chapter struct {
	models.BaseModel

	Content   string `json:"content,omitempty"`
	Timestamp string `json:"timestamp,omitempty"`

	models.CommonTimestampsField
}

// Create 创建，通过 Chapter.ID 来判断是否创建成功
func (chapterModel *Chapter) Create() {
	database.DB.Create(&chapterModel)
}

func (chapterModel *Chapter) Save() (rowsAffected int64) {
	result := database.DB.Save(&chapterModel)
	return result.RowsAffected
}
